home *** CD-ROM | disk | FTP | other *** search
-
-
- ##########################################################################
- #
- # LOGIN.CMD v0.8 (Gen-A-Sys)
- #
- # A trumpet winsock login script for users of Sonic (West Sonoma County).
- # ----------------------------------------------------------------------
- #Abstract:
- #
- # The default LOGIN.CMD shipped with trumpet winsock is NOT a "catch all"
- #script designed to work on everything, nor does it catch configuration
- #problems or provide any serious diagnostic feedback to the user.
- #
- # This script is designed to replace the default login.cmd file,
- #provides for extreamly robust error handling, and will work "out of the box"
- #in more configurations that the default login script ever could. It
- #makes provisions for quite a few odd situations that would normally
- #prevent a less-able script from connecting.
- #
- #
- # *** This version is for testing purpose only, release to persons outside
- # of the testing group, while not prohibited, is NOT reccomended! ***
- #
- #
- # "Can you say, Overkill?...."
- #
- #Mike Ireton [qix@sonic.net]
- #
- # if ! %ppp" statement - since sonic only supports PPP, this is how we'll
- # catch users who try to login ppp but have trumpet configured for slip.
- #
- #
- if ! %ppp
- Display \n\nERROR:\nSonic only supports PPP, please re-configure\N
- Display Trumpet to use INTERNAL PPP (under the FILE, Setup menu)\n
- Display and then try again.\n
- abort
- end
-
-
- #
- # Get Phone number, username and password.
- #
- if ![load $number]
- if [query $number "Enter your dial up phone number"]
- save $number
- end
- end
- if ![load $username]
- if [username "Enter your login username"]
- #
- # It would be nice to try and catch illegal usernames here, but then
- # we'd have to make the same edits to setup.cmd and then it'd be a
- # maintinence nightmare. We'll catch these later on in the script.
- #
- #
- save $username
- end
- end
- if ![load $password]
- if [password "Enter your login password"]
- save $password
- end
- end
- #
- # Fix #1: Initializing the modem.
- # -------------------------------
- #
- # By default, we should assume that the user's modem will simply
- # work properly if we give it an ATZ command. Trumpet's default
- # script wants to send "&c1&k3", which may not be recognised by
- # all modems, and which may be interpreted differently by diferent
- # modems.
- #
- # Any user who has a modem that cannot connect to sonic given thier
- # modems' default configuration (via ATZ), more than likely has a
- # configuration problem that will need to be addressed first.
- #
- # USER CONFIGURATION VARIABLES
- #
- $modemsetup = "ATZ"
- %attempts = 0
- %inittime = 5
- %debuglevel = 1
- #----------------------------
- #
- # Script constants that should never be altered
- # ---------------------------------------------
- #
- # You should not ever have to change the command prefix string, unless you
- # are using a modem that is not hayes compatible, in which case you will
- # will have to change lots of other things, in which case you would probbly
- # be better off writing a login script from scratch!
- #
- $cmdprefix = "AT"
- $dialprefix = "ATDT"
- #
- # You should not ever have to change the "connect" string - that is, a
- # recognisable sequence of characters your modem will send out whenever
- # you make a connection to another modem. Some modems will send out things
- # like "CARRIER xxxx" and "PROTOCOL xxxx" and _then_ "CONNECT xxxx" -
- # the message should always be keyed to the very last line your modem will
- # return when a connect is made.
- #
-
- $connect = "CONNECT"
- $okprefix = "OK"
- $errorprefix = "ERROR"
- #
- # You should never *ever* have to modify these, unless Sonic has a
- # _serious_ change of hardware (gets ported to the playstation? hahaha)
- #
- $userprompt = "login:"
- $passprompt = "assword:"
- #
- #
- #----------------------------------------------------------
- #
- # Fix #2: Actually doing the modem initialization.
- # ------------------------------------------------
- #
- # Here is our first opportunity to catch misconfigured hardware or
- #software. We will send out the "modemsetup" string, and see wether or
- #not we get an ok response.
- #
- # If we get an ERROR response, we should inform the user of this - It means
- # that some portion of the init string was NOT understood, and that the login
- # process will not continue (until they correct the error).
- #
- # If we don't get any response at all, that means one of:
- #
- # 1) The user is already online and connected.
- # 2) The user has selected the wrong com port and bps setting
- # 3) Their hardware is broken.
- # 4) Their hardware is not hayes compatible (We can't support it)
- #
- # We can't rely on DCD to determine status, as a number of other software
- # packages on the market (PcAnywhere, for example) incorrectly sets DCD
- # "On at all times" for no good reason other than to do it. Since we might
- # be subject to a "residue" issue with another modem package, we avoid
- # the issue entirely and act as if this signal was not available (and take
- # the long way around).
- #
- output \b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\n
- sleep 2
-
- output $modemsetup\n
-
- #--------------------------------
- # The start of a big loop -
- #
- # We begin by getting input from the modem to determine wether or not
- # we recognise the response. We'll loop up to 3 times around to get
- # something we recognise and if we don't see it we'll give up and
- # die.
- %i = 0
- repeat
-
- if ! [read 15 $result]
-
- display DEBUG: Your modem is NOT responding to commands!\n
- display DEBUG: -----------------------------------------\n
- display DEBUG: This can be caused by any of the following:\n\n
- display DEBUG: 1) You already are online and connected.\n
- display DEBUG: 2) You have specfied an incorrect comport or baud rate for your modem.\n
- display DEBUG: 3) Your modem is defective. \n
- display DEBUG: Correct this situation and try again.\n
- display DEBUG: Script Aborting.\n
- abort
-
- end
-
- %yok = pos($okprefix,$result) > 0
- %yerror = pos($errorprefix,$result) > 0
- %break = %i > 2 | %yok | %yerror
-
- until %break
-
- if %i > 2
-
- display DEBUG: We went thru three inputs? Phone's probbly ringing\n
- display DEBUG: Dialing script aborted.
- abort
- end
-
- if %yerror
- display Your modem returned ERROR in response to the init string, aborting.\n
- abort
- end
- if %debuglevel > 1
- display DEBUG: Everything looks good, going to try to dial the phone.\n
- end
-
- #
- #
- #
- #
- # send phone number
- #
- # Fix #3: Dialing the phone
- # -------------------------
- #
- # The dial loop provided by the default login script is pretty weak, as
- # it will not catch errors in the dialing string, badly handles BUSY
- # signals, and does not take into account the possibillity of a RING
- # response.
- #
- #
- %dials = 0
- repeat
- #
- # Outer dialing loop begins here.
- #
- # First check to see that we haven't exceeded our max number of
- # dial attempts (0 = unlimited)
- #
- if ! %attempts = 0
- if %i = %attempts
- display "Too many dial attempts"\n
- abort
- end
- end
- output $dialprefix$number\n
-
- %i = 0
- %busy = 0
- %connected = 0
- %timeout = 0
- repeat
-
- if [READ 60 $result]
- #
- # We did get a response of some sort, try to deal with it.
- # Some weird off brand modems that users will try to use (in the name
- # of saving a buck) will sometimes return odd strings like "voice call" or
- # "NO CARRIER" in response to busy signals or timed-out connect attempts.
- # Let's make sure we'll never choke if we see an unexected response...
- #
-
- %connected = pos($connect,$result)
- if ! %connected
- #
- # We didn't get a connect response, see if we can match it.
- #
- if pos("BUSY",$result)
- %busy = 1
- end
-
- if pos("RING",$result)
- display Incomming call detected, aborting...\n
- abort
- end
-
- if pos("ERROR",$result)
- display Modem rejected dial command, aborting...\n
- abort
- end
- #
- # We did not match the string... Oh well. We will have to rely on
- # the input timeout and the max loop count to save us from insanity.
- #
- # Some users complained about getting the message the following message
- # for their dial string, so we have this off by default (increase debuglevel
- # to re-enable it).
- if %debuglevel > 1
- display DEBUG: We got back $result but do not understand it!\n
- end
- %i = %i + 1
- end
-
- else
- display DEBUG: We timed out waiting for a response string from the modem.\n
- display DEBUG: Aborting...\n
- %timeout = 1
-
- end
- until %connected | %busy | %timeout
-
- # and another for the outer loop.
- until %connected
- #
- #
- # Fix #4: Actually logging in
- # ---------------------------
- #
- # We need to keep an eye out to make sure the user has supplied a valid
- # username and password combonation. Some users may give us "username.ppp",
- # others just "username", and still others will supply a bogus username /
- # password pair. This part of the script filters all these possibillities
- # out. In testing sonic's current equipment (2/17/96), it seems that users
- # can login as userneme.ppp.ppp and that will work.
- #
- input 30 $userprompt
- output $username
- if ! pos(".ppp",$username)
- output .ppp
- end
- output \n
-
- #
- # and the password
- #
- input 30 $passprompt
- output $password\n
- #
- # We now need to look for two things:
- # Invalid password
- # PPP session
- #
- # Trumpet does not have a good way to do this, as it lacks multiple target
- # patttern matching and program flow control. We'll take the ugly way out and
- # assume that if we don't see the PPP startup message, that something else
- # is going on and then user can follow onscreen instructions.
- #
- #
- if ! [input 15 "PPP ses"]
- display \nDEBUG: We did not see the PPP startup message within 15 seconds.\n
- display DEBUG: --------------------------------------------------------\n
- display DEBUG: If there is a message above these lines that states "Invalid Login",\n
- display DEBUG: then you have either entered your login information incorrectly in\n
- display DEBUG: SETUP, or there is a problem with your account. Please re-enter your\n
- display DEBUG: username and password, then try again.\n\n
- display DEBUG: If there is NOT and "Invaid Login" message above, then most likely there\n
- display DEBUG: is a temporary hardware problem at Sonic, and you should probbly try\n
- display DEBUG: this again later.\n
- display DEBUG: Script Aborting.\n
- abort
- end
- #
- # we are now logged in. Check for 0.0.0.0 allocation....
- #
- if [input 2 "0.0.0.0"]
- display DEBUG: Whoops! You've been assigned an invalid ip address of 0.0.0.0\n
- display DEBUG: Try connecting again. If this problem persists, call\n
- display DEBUG: Sonic technical support and report it.\n
- display DEBUG: Script Aborted.
- abort
- end
- if %debuglevel > 1
- Display \nDEBUG: We have a sucessful login!\N
- end
-